<?php
/**
 * Created by PhpStorm.
 * User: alice
 * Date: 2015/12/28
 * Time: 12:26
 */

/**
 * Class Involved_InquiryModel
 */

class Involved_InquiryModel extends BaseModel{

    protected $table = 'inquiry';

    /**
     * 获取询价单列表
     * @return mixed
     * @author alice
     * @date 2016-1-26
     */
    public function GetInquiryList($is_self,$page,$user_id)
    {
        $offset = ($page-1) * HostEnum::PAGE_NUM;

        $where = [];
        if($is_self == 1)
            $where['supplier_id'] = $user_id;

        return  DB::table($this->table)
            ->select('inquiry_id','product_name','spec','supplier','created','supplier_id','number')
            ->where($where)
            ->skip($offset)->take(HostEnum::PAGE_NUM)
            ->get();
    }

    /**
     * 获取询价信息
     * @param $supply_id
     * @return mixed
     * @author alice
     * @date 2016-2-16
     */
    public function GetInquiryInfo($supply_id)
    {
        #获取询价单信息
        return DB::table($this->table)
                ->select('supplier','number')
                ->where('supply_id',$supply_id)
                ->get();
    }

    /**
     * 获取询价数量
     * @param $supply_id
     * @return mixed
     * @author alice
     * @date 2016-2-16
     */
    public function GetInquiryNum($supply_id)
    {
        return DB::table($this->table)
                ->where('supply_id', $supply_id)
                ->count();
    }
    public function InquiryList()
    {
        return  DB::table($this->table)->get();
    }
















}